package com.zyj.mds.service;

import com.zyj.mds.annotation.DataSource;
import com.zyj.mds.config.DataSourceEnum;
import com.zyj.mds.dao.UselessDataDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AspectTestService {

    @Autowired
    private AspectTestService thisService;

    @Resource
    private UselessDataDao uselessDataDao;

    public void testAspectQuery() {
        thisService.firstQuery();
        thisService.secondQuery();
    }

    @DataSource(DataSourceEnum.DB1)
    public void firstQuery() {
        System.out.println("第一次查询-------------------------");
        uselessDataDao.findAll().forEach(System.out::println);
        System.out.println();
    }

    @DataSource(DataSourceEnum.DB2)
    public void secondQuery() {
        System.out.println("第二次查询-------------------------");
        uselessDataDao.findAll().forEach(System.out::println);
    }

}
